package com.Lixiaoqian.PartyHistoryMuseum.base;

import android.app.Application;
import android.content.Context;
import android.support.multidex.MultiDex;

import com.Lixiaoqian.PartyHistoryMuseum.bean.BannerData;
import com.Lixiaoqian.PartyHistoryMuseum.net.ApiFactory;
import com.Lixiaoqian.PartyHistoryMuseum.net.BannerApi;
import com.Lixiaoqian.PartyHistoryMuseum.utils.BetaConstant;
import com.tencent.bugly.Bugly;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

/**
 * Created by huangzhibo on 2017/9/13/013.
 * mail:1043202454@qq.com
 */

public class MyApplication  extends Application{
    private static Context instance;
    public static String wikitude_res_path="Scanner_Test/index.html";
    public static BannerData bannerDataList;
    public static BannerData voiceDataList;
    @Override
    public void onCreate() {
        super.onCreate();
        instance = getApplicationContext();
        Bugly.init(getApplicationContext(),"8c87574b09", BetaConstant.isOpendebug);
        getVideListApi("videoSource");
        getVideListApi("voiceSource");
        MultiDex.install(this);

    }


    private void getVideListApi(final String source){
        BannerApi bannerApi = ApiFactory.getBannerApiSingleton();
        final Call<BannerData> banner = bannerApi.getBanner("20170918142913345082", source);
        banner.enqueue(new Callback<BannerData>() {
            @Override
            public void onResponse(Call<BannerData> call, Response<BannerData> response) {
                if (source.equals("videoSource")){
                    bannerDataList = response.body();
                }else{
                    voiceDataList=response.body();
                }
            }

            @Override
            public void onFailure(Call<BannerData> call, Throwable t) {

            }
        });
    }
    public static Context getContext() {
        return instance;
    }
}
